package com.example.mobiledatapackage.request;


import com.example.mobiledatapackage.domain.User;
import com.example.mobiledatapackage.domain.UsingStatus;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;

@Data
@Builder
@NoArgsConstructor
@AllArgsConstructor
public class UserStatus {
    private String pkgId;  // 用户当前使用的业务套餐
    private String name;
    private Double usedDomesticData;
    private Double usedOverseaData;
    private Integer usedDomesticMsg;
    private Integer usedOverseaMsg;
    private Double usedDomesticVoiceCall;
    private Double usedOverseaVoiceCall;
    private Double usedDomesticVoiceRecv;
    private Double usedOverseaVoiceRecv;
    // 用户的 APP 偏好
    @Schema(description = "用户的APP偏好，其值为表 app_series 中的 seriesId")
    private String appPreference1;
    private String appPreference2;
    private String appPreference3;

    public static UserStatus valueOf(User user, UsingStatus usingStatus) {
        return UserStatus.builder()
                .pkgId(usingStatus.getPkgId())
                .name(user.getNickname())
                .usedDomesticData(usingStatus.getUsedDomesticData())
                .usedOverseaData(usingStatus.getUsedOverseaData())
                .usedDomesticMsg(usingStatus.getUsedDomesticMsg())
                .usedOverseaMsg(usingStatus.getUsedOverseaMsg())
                .usedDomesticVoiceCall(usingStatus.getUsedDomesticVoiceCall())
                .usedOverseaVoiceCall(usingStatus.getUsedOverseaVoiceCall())
                .usedDomesticVoiceRecv(usingStatus.getUsedDomesticVoiceRecv())
                .usedOverseaVoiceRecv(usingStatus.getUsedOverseaVoiceRecv())
                .appPreference1(usingStatus.getAppPreference1())
                .appPreference2(usingStatus.getAppPreference2())
                .appPreference3(usingStatus.getAppPreference3())
                .build();
    }
}
